home *** CD-ROM | disk | FTP | other *** search
- /* Trap numbers. Usually used when patching ToolBox routines.
-
- Revision History:
-
- 91/04/19 AIH
- - Added Gestalt trap and functions documented in IM-VI for checking
- if a trap is available
-
- 91/02/28 Ari Halberstadt (AIH)
- - Created this file */
-
- #include "TrapLib.h"
-
- /* Functions for determining whether a trap is available. Based on
- functions given in IM VI. */
-
- /* return number of toolbox traps */
- short TrapNumToolbox(void)
- {
- short result = 0;
-
- if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
- result = 0x0200;
- else
- result = 0x0400;
- return(result);
- }
-
- /* return the type of the trap */
- TrapType TrapTypeGet(short trap)
- {
- return((trap & 0x0800) > 0 ? ToolTrap : OSTrap);
- }
-
- /* true if the trap is available */
- Boolean TrapAvailable(short trap)
- {
- TrapType type;
-
- type = TrapTypeGet(trap);
- if (type == ToolTrap) {
- trap &= 0x07FF;
- if (trap >= TrapNumToolbox())
- trap = _Unimplemented;
- }
- return(NGetTrapAddress(trap, type) != NGetTrapAddress(_Unimplemented, ToolTrap));
- }
-